#ifndef DOWNLOADMODEL_H
#define DOWNLOADMODEL_H

#include "downloadmanager.h"

#include <QSqlTableModel>
#include <QVariant>
#include <QModelIndex>
#include <QString>
#include <QMap>

class DownloadModel : public QSqlTableModel
{
    Q_OBJECT

    DownloadManager* mgr_;

    QMap<int, int> primaryToRow;
    QMap<int, QString> statusMap;
    void takeCareOfOldDownloads();
public:
    DownloadModel(QObject* parent = 0);
    ~DownloadModel();
    QVariant data ( const QModelIndex & index, int role = Qt::DisplayRole ) const;
    void enqueueNewTask(TaskRecord* record);
private slots:
    void updateTask(int id, QSqlRecord* record);
    void buildPrimaryToRow();
public slots:

};

#endif // DOWNLOADMODEL_H
